package com.jifeng.br.pjj.bookreader.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jifeng.br.pjj.bookreader.entity.CategoryEntity;
import com.jifeng.br.pjj.bookreader.mapper.CategoryMapper;
import com.jifeng.br.pjj.bookreader.service.CategoryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 分类表 服务实现类
 * </p>
 *
 * @author 机蜂
 * @since 2023-07-11
 */
@Service
@Transactional
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryEntity> implements CategoryService {
    @Override
    public IPage<CategoryEntity> getPage(int page, int limit, CategoryEntity category) {
        return this.page(new Page<>(page, limit), new QueryWrapper<CategoryEntity>()
                .eq(StringUtils.isNotEmpty(category.getCategoryName()), "category_name", category.getCategoryName())
                .eq(category.getStatus() != null, "status", category.getStatus())
        );
    }
}
